<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        .box {
            display: flex;
            justify-content: center;
            align-items: center;
            width: 200px;
            height: 200px;
            margin: 100px auto;
            background-color: skyblue;
            font-size: 40px;
            color: #fff;
            cursor: pointer;
            transition: all .3s;
        }

        .change-big {
            width: 300px;
            height: 300px;
            font-size: 50px;
        }

        .change-small {
            width: 100px;
            height: 100px;
            font-size: 16px;
        }
    </style>
</head>

<body>

    <div class="box">盒子</div>

    <script>

        // - 改变盒子大小
        //     - 编写HTML，设置div的大小。
        //     - 根据用户的点击次数完成盒子大小的改变。
        //     - 单击的次数为奇数时，盒子都变大，单击次数为偶数时，盒子都变小。

        var box = document.getElementsByClassName('box')[0];
        var n = 0;
        box.addEventListener('click', function () {
            n++;
            if (n % 2 == 0) {
                box.className = 'box change-small';
                box.innerHTML = '变成小盒子'
            } else {
                box.className = 'box change-big';
                box.innerHTML = '变成大盒子'
            }
        });

    </script>

</body>

</html>